import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.HashMap;

import javax.swing.JOptionPane;


public class AdminAccountGenerator {

	public static void maind(String[] args) {
		HashMap<String, User> users = new HashMap<String, User>();
		User admin = new User("admin", "password");
		users.put(admin.getUsername(), admin);
		try {
            ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("users.dat"));
            oos.writeObject(users);
            oos.close();

            JOptionPane.showMessageDialog(null, "Got here");
            ObjectInputStream ois = new ObjectInputStream(new FileInputStream("users.dat"));
            users = (HashMap<String, User>)ois.readObject();
            ois.close();

            if (!users.containsKey("admin"))
            	throw new Exception();

            JOptionPane.showMessageDialog(null, "Worked!");
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, e.getMessage());
            e.printStackTrace();
        }
	}

}
